package com.my.hp_hr.contorller;

import com.my.hp_hr.entity.Department;
import com.my.hp_hr.service.DepartmentService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;

// @WebServlet("/pageNoServlet")
public class PageNo extends HttpServlet {
    /*@Override*/
   /* protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        try {
            req.setCharacterEncoding("utf-8");
            String pageNo = req.getParameter("pageNo");
            if (pageNo==null){
                pageNo="1";
            }
            DepartmentService departmentService = new DepartmentService();
            List<Department> list = departmentService.getPageList(pageNo);
            req.setAttribute("list",list);
            System.out.println(list);
            int count = departmentService.getPageCount();
            req.setAttribute("count",count);
            int totalPage = (int)Math.ceil(count / 5.0);
            req.setAttribute("totalPage",totalPage);
            req.setAttribute("pageNo", Integer.parseInt(pageNo));
            req.getRequestDispatcher("department_list.jsp").forward(req,resp);
        } catch (Exception e) {
            e.printStackTrace();
        }
    }*/

    @Override
    protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
        doGet(req, resp);
    }
}
